package com.study.sxc.Dao;

import com.study.sxc.Entity.Staff;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface IStaffDao {
    @Select({
        "<script>",
        "SELECT staff_id AS staffId, name AS staffName, contact, role",
        "FROM Staff",
        "WHERE staff_id IN",
        "<foreach collection='list' item='id' open='(' separator=',' close=')'>",
        "#{id}",
        "</foreach>",
        "</script>"
    })
    List<Staff> getStaffs(List<Integer> ids);

    @Insert("INSERT INTO Staff (name, contact, role) VALUES (#{staffName}, #{contact}, #{role})")
    @Options(useGeneratedKeys = true, keyProperty = "staffId")
    int addStaff(Staff staff);

    @Update("UPDATE Staff SET name = #{staffName}, contact = #{contact}, role = #{role} WHERE staff_id = #{staffId}")
    int updateStaff(Staff staff);

    @Delete("DELETE FROM Staff WHERE staff_id = #{id}")
    int deleteStaff(Integer id);

    @Select("SELECT staff_id AS staffId, name AS staffName, contact, role FROM Staff WHERE staff_id = #{id}")
    Staff getStaffById(Integer id);

    @Select("SELECT staff_id AS staffId, name AS staffName, contact, role FROM Staff")
    List<Staff> getAllStaffs();
} 